updating oE show_help

show_help

include cmdline.e 
namespace cmdline 
public procedure show_help(sequence opts, object add_help_rid = - 1, 
        sequence cmds = command_line(), object parse_options = {}) 

shows the help message for the given opts.

Parameters:
  1. opts : a sequence of options. See the cmd_parse for details.
  2. add_help_rid : an object. Either a routine_id or a set of text strings. The default is -1 meaning that no additional help text will be used.
  3. cmds : a sequence of strings. By default this is the output from command_line
  4. parse_options : An option set of behavior modifiers. See the cmd_parse for details.
Comments:
  • opts is identical to the one used by cmd_parse
  • add_help_rid can be used to provide additional help text. By default, just the option switches and their descriptions will be displayed. However you can provide additional text by either supplying a routine_id of a procedure that accepts no parameters; this procedure is expected to write text to the stdout device. Or you can supply one or more lines of text that will be displayed.
Example 1:
-- in myfile.ex 
constant description = { 
       "Creates a file containing an analysis of the weather.", 
       "The analysis includes temperature and rainfall data", 
       "for the past week." 
    } 
 
show_help({ 
    {"q", "silent", "Suppresses any output to console", NO_PARAMETER, -1}, 
    {"r", 0, "Sets how many lines the console should display",  
    {HAS_PARAMETER,"lines"}, -1}}, description) 

Outputs:

myfile.ex options: 
-q, --silent      Suppresses any output to console 
-r lines          Sets how many lines the console should display 
 
Creates a file containing an analysis of the weather. 
The analysis includes temperature and rainfall data 
for the past week. 

Example 2:
-- in myfile.ex 
constant description = { 
       "Creates a file containing an analysis of the weather.", 
       "The analysis includes temperature and rainfall data", 
       "for the past week." 
    } 
procedure sh() 
  for i = 1 to length(description) do 
     printf(1, " >> %s <<\n", {description[i]}) 
  end for 
end procedure 
 
show_help({ 
    {"q", "silent", "Suppresses any output to console", NO_PARAMETER, -1}, 
    {"r", 0, "Sets how many lines the console should display",  
     {HAS_PARAMETER,"lines"}, -1}}, routine_id("sh")) 

Outputs:

myfile.ex options: 
-q, --silent      Suppresses any output to console 
-r lines          Sets how many lines the console should display 
 
>> Creates a file containing an analysis of the weather. << 
>> The analysis includes temperature and rainfall data  << 
>> for the past week.  << 

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu